package cn.miao.middle.cloud.core.config;

import javax.annotation.Resource;

import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import cn.miao.middle.cloud.core.interceptor.ApiIdempotentInterceptor;
import cn.miao.middle.cloud.redis.util.RedisUtil;

/**
 * 幂等拦截配置
 * 
 * @author kongyufei
 *
 */
@Configuration
@ConditionalOnClass(WebMvcConfigurer.class)
public class ApiIdempotentConfig implements WebMvcConfigurer {

	@Resource
	private RedisTemplate<String, Object> redisTemplate;

	@Resource
	private RedisUtil redisUtil;

	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		registry.addInterceptor(new ApiIdempotentInterceptor(redisTemplate)).addPathPatterns("/**");

	}
}
